<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('test','IndexController@test');
Route::any('wechat',   'WechatController@serve');
Route::any('wechat-company',   'WechatController@serveCompany');
Route::any('create-menu',   'WechatController@createMenu');
Route::any('create-company-menu',   'WechatController@createCompanyMenu');
Route::any('upload','UploadController@upload');




Route::get('logout',   'LoginController@logOut');

// Route::get('reg',	   'RegisterController@index');
// Route::any('regdo',	   'RegisterController@regdo');
// Route::get('sendmsg',  'IndexController@sendmsg');
// Route::get('getarea',  'IndexController@getArea');
//Route::get('push-msg' ,'IndexController@pushMsg');
Route::middleware(['wechat.oauth'])->group(function(){
	Route::get('login',    'LoginController@login');
 	Route::any('logindo', 'LoginController@loginDo');
});

Route::prefix('company')->namespace('Company')->group(function(){
	//Route::middleware(['wechat.oauth:work'])->group(function(){
		Route::get('task/show/{id}',		'TaskController@show');
		Route::post('task/save',    'TaskController@save');
		Route::get('task/create', 	'TaskController@create');
		
		Route::post('task/process-price', 'TaskController@processPrice');
		Route::post('task/process-complete','TaskController@processComplete');
		Route::post('task/comment','TaskController@comment'); 
		Route::get('task/', 		'TaskController@index');
	//});
});


Route::middleware(['web'])->prefix('user')->namespace('User')->group(function(){
	Route::prefix('task')->group(function(){
		Route::post('process',       'TaskController@process');
		Route::middleware(['wechat.oauth'])->group(function(){
			Route::get('create', 	 'TaskController@create');
			Route::post('save',  	 'TaskController@save');
			Route::any('complete',	 'TaskController@complete');
			Route::get('show/{id}',  'TaskController@show');
			Route::get('edit/{id}',  'TaskController@edit');
			Route::post('update',     'TaskController@update');
			Route::any('reply',       'TaskController@reply');
			
			Route::any('process-price', 'TaskController@processPrice');	
			Route::get('price-detail/{id}',  'TaskController@priceDetail');		
			Route::any('price-confirmed','TaskController@priceConfirmed');
			
			// 报修任务完成		
			Route::any('process-complete','TaskController@processComplete');

			Route::any('comment',  'TaskController@comment');
			Route::any('refund',   'TaskController@refund');
			Route::get('/',        'TaskController@index');
		
		});
			
	});
	
	Route::get('/',        'IndexController@index');
});

Route::prefix('zadmin')->namespace('Admin')->group(function(){
	Route::middleware('checkAdmin')->group(function(){
		Route::get('test','IndexController@test');
		Route::get('system-info','SystemController@info');
		Route::get('system-update','SystemController@update');
		Route::prefix('task')->group(function(){
			
			Route::get('show/{id}',  'TaskController@show');
			Route::get('print/{id}',  'TaskController@print');
			Route::get('check/{id}', 'TaskController@check');
			Route::any('complete',	'TaskController@complete');
			Route::get('add',        'TaskController@add');
			Route::post('save',      'TaskController@save');
			Route::get('buyer-task/{task_id}',   'TaskController@buyerTask');
			Route::get('del/{id}',   'TaskController@del');

			// 导出
			Route::get('export','TaskController@taskExport');
			
			// 回复任务
			Route::any('reply', 'TaskController@reply');


			Route::get('/','TaskController@index');
		});

		
		Route::resource('admins',     'AdminController');
		Route::resource('users',      'UserController');
		Route::resource('roles',      'RoleController');
		Route::resource('menus',      'MenuController');
		Route::resource('depart',     'DepartController');
		Route::resource('services',   'ServiceController');
		Route::resource('articles',   'ArticleController');
		Route::get('menus/permission/{menu_id}', 'MenuController@menuPermission');
		Route::resource('permissions', 'PermissionController');	
		Route::resource('category',   'CategoryController');	
		Route::resource('system','SystemController');
		Route::resource('comment','TaskCommentController');

		// 工种管理
		Route::resource('worktype',   'WorktypeController');	

		
		

		Route::prefix('wechat')->group(function(){
			Route::get('wxuser/pull',  'WxuserController@pull');
			Route::get('wxuser/import',  'WxuserController@import');
			Route::post('wxuser/save-user','WxuserController@saveToUser');

			
			Route::get('wxuser/company-user',  'WxuserController@companyUser');
			Route::get('wxuser/company-user-edit/{id}',  'WxuserController@companyUserEdit');
			Route::post('wxuser/company-user-update/{id}',  'WxuserController@companyUserUpdate');
			Route::get('wxuser/company-user-del/{id}',  'WxuserController@companyUserDel');
			Route::get('wxuser/company-import',  'WxuserController@companyImport');
			Route::get('wxuser/pull-company',  'WxuserController@company');
			Route::resource('wxuser',  'WxuserController');

			
			
			
			Route::get('msgtpl',     'MsgtplController@index');
			Route::get('msgtpl-show/{tpl_key}','MsgtplController@show');
			Route::get('msgtpl-edit/{tpl_key}','MsgtplController@edit');
			Route::post('msgtpl-save',         'MsgtplController@save');
			Route::get('msgtpl-del/{tpl_key}', 'MsgtplController@del');
			Route::get('msgtpl-import','MsgtplController@import');
			Route::get('msgtpl-all','MsgtplController@all');
			Route::get('menu','WxMenuController@index');

			// 素材管理
			Route::any('get-material','WxMaterialController@getMaterial');

			Route::get('material-downvideo','WxMaterialController@downVideo');

			// 发送消息到个人
			Route::any('send-msg','WxMsgController@sendMsg');
		});


		
		

		// 统计报表
		Route::prefix('census')->group(function(){
			Route::any('worker-count','CensusController@workerCount');
			Route::any('worker-count-export','CensusController@workerCountExport');
		});

		// 服务信息
		Route::resource('notice','NoticeController');
		Route::resource('worklog','WorklogController');
		Route::resource('worker','WorkerController');

		
		//退单 
		Route::post('refund','IndexController@refund');

		//派工
		Route::post('process','IndexController@process');

		//后台首页
		Route::get('/',		   'IndexController@index');
		
	});
		Route::get('login',    'LoginController@login');
		Route::post('logindo', 'LoginController@loginDo');
		Route::get('logout',   'LoginController@logOut');
		
	
});






